package com.xtwy.admin.web.service.impl;

import com.xtwy.admin.web.mapper.RoleAndMenuMapper;
import com.xtwy.admin.web.model.pojo.RoleAndMenu;
import com.xtwy.admin.web.service.RoleAndMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * 类的描述：
 *
 * @作者: 侯建军
 * @邮箱: 474177818@qq.com
 * @博客: https://blog.csdn.net/marquis888
 * @创建日期: 2018年11月18日  23:11
 * @版本: v1.0
 * @jdk版本使用: JDK1.8
 */
@Service
public class RoleAndMenuServiceImpl implements RoleAndMenuService{
    @Autowired
    private RoleAndMenuMapper roleAndMenuMapper;

    public void insert(RoleAndMenu roleMenu){
        roleAndMenuMapper.insert(roleMenu);
    }

    public void deleteMenuId(String id){
        Example example = new Example(RoleAndMenu.class);
        example.createCriteria().andCondition("menu_id =", id);
        roleAndMenuMapper.deleteByExample(example);
    }

    public void deleteRoleId(String id){
        Example example = new Example(RoleAndMenu.class);
        example.createCriteria().andCondition("role_id =", id);
        roleAndMenuMapper.deleteByExample(example);
    }

    public RoleAndMenu selectOne(RoleAndMenu roleMenu){
        return roleAndMenuMapper.selectOne(roleMenu);
    }

    public List<RoleAndMenu> getRoleList(RoleAndMenu roleMenu){
        return roleAndMenuMapper.select(roleMenu);
    }
}
